//
//  ViewController.m
//  LBAlert
//
//  Created by LINAICAI on 2017/7/31.
//  Copyright © 2017年 LINAICAI. All rights reserved.
//

#import "ViewController.h"
#import "LBAlert.h"
#import "LBAlertMessage.h"
#import "LBAlertView.h"
#import "LBJobMBTIIntroducationView.h"
#import "LBJobInputHunterServiceTipsPopView.h"
#import <LBActionSheet.h>
#import <LBPhotoBrowser.h>
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];

       // Do any additional setup after loading the view, typically from a nib.
}
- (NSArray *)datasoutces{
    return @[@"最基本的提示框",@"最基本的询问框",@"富文本提示内容(左对齐)",@"成功图片提示",@"错误图片提示",@"自定义图片信息提示",@"图片+文本信息提示",@"图片+富文本信息提示",@"带输入框的提示(UITextView)",@"自定义视图的提示",@"图片+富文本信息提示2",@"富文本提示内容(居中对齐)",@"头部图片+基本信息",@"头部图片+副文本信息",@"带输入框的提示(UITextField)",@"没有头部的自定义视图",@"弹出框上再present一个控制器(逆天需求别问为什么)",@"没有脚部的自定义视图(关闭按钮使用自定义图片)"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self datasoutces].count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identity"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identity"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = [self datasoutces][indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            [LBAlert say:^(NSInteger answer) {
                NSLog(@"点击了按钮:%ld",answer);
            } title:@"提示一次" message:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
        }
            break;
        case 1:
        {

            [LBAlert ask:^(NSInteger answer) {
                NSLog(@"answer=%ld",(long)answer);
                
            } message:@"专业、权威的建设人才职业性格测评，邀请好友一起来来测评" buttons:@[@"查看测评报告",@"分享到朋友圈"]];
        }
            break;
        case 2:
        {
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(0, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(31, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(61, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(97, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(140, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(188, 2)];
            
            [LBAlert show:^(NSInteger answer) {
                
            } title:@"议标须知" attributedMessage:attributedString buttons:@[@"知道了"]];
        }
            break;
        case 3:
        {
                [LBAlert showSuccessWithTitle:@"提示" message:@"投标邀请函已发送" buttons:@[@"确定"] block:^(NSInteger answer) {
                    
                }];
        }
            break;
        case 4:
        {
            [LBAlert showErrorWithTitle:@"提示" message:@"投标邀请函发送失败" buttons:@[@"确定"] block:^(NSInteger answer) {
                
            }];
        }
            break;
        case 5:
        {
            //图片文本信息            
            [LBAlert showImageWith: [UIImage imageNamed:@"test"] title:@"联结建设人才职业性格测评说明" message:@"1、共28题，建议用时5-10分钟完成\n2、本测试基于近况而非未来的判断，给予专业建议和资料\n3、凭第一感觉完成作答，结果会更准确" buttons:@[@"马上测评"] block:nil
             ];
        }
            break;
        case 6:
        {
            //图片+文本信息
            [LBAlert showHeaderImage:[UIImage imageNamed:@"header"] message:@"专业、权威的建设人才职业性格测评，邀请好友一起来测评" buttons:@[@"查看测评报告",@"分享到朋友圈"]];
        }
            break;
        case 7:
        {
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(0, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(31, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(61, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(97, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(140, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(188, 2)];
            //图片+富文本信息
            [LBAlert showHeaderImage: [UIImage imageNamed:@"header"] attributedMessage:attributedString buttons:@[@"知道了"]];
        }
            break;
        case 8:
        {
            //输入框提示
            [LBAlert showInputTextViewWithTitle:@"添加问题" message:@"你好" limit:350 placeholder:@"在这里填写问题库，最多350字" buttons:@[@"取消",@"保存"] block:^(LBAlertInputTextView *input , NSInteger answer) {
                NSLog(@"点击了按钮%ld",(long)answer);
                NSLog(@"输入了内容:%@",input.textView.text);
            } hasCloseButton:NO];
        }
            break;
        case 9:
        {
            //自定义视图提示
            LBJobMBTIIntroducationView *view = [[LBJobMBTIIntroducationView alloc]init];
            [LBAlert showCustom:view title:@"提示" buttons:@[@"取消",@"保存"] block:^(NSInteger answer) {
                
            } hasCloseButton:NO];
        }
            break;
        case 10:
        {
            //图片+富文本信息提示2
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"尊贵的企业用户，感谢您使用联结招应聘猎头服务！\n①  请填写服务需求\n②  猎头顾问会在2天内与您联系"];
            
            NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
            [paragraphStyle setLineSpacing:10];
            [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [attributedString length])];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:69 / 255.0f green:69 / 255.0f blue:69 / 255.0f alpha:1.0f] range:NSMakeRange(0, 23)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:68 / 255.0f green:198 / 255.0f blue:77 / 255.0f alpha:1.0f] range:NSMakeRange(24, 1)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:68 / 255.0f green:198 / 255.0f blue:77 / 255.0f alpha:1.0f] range:NSMakeRange(35, 1)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(44, 3)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153 / 255.0f green:153 / 255.0f blue:153 / 255.0f alpha:1.0f] range:NSMakeRange(27, 7)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153 / 255.0f green:153 / 255.0f blue:153 / 255.0f alpha:1.0f] range:NSMakeRange(38, 6)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153 / 255.0f green:153 / 255.0f blue:153 / 255.0f alpha:1.0f] range:NSMakeRange(47, 4)];
             [LBAlert showHeaderImage: [UIImage imageNamed:@"填写服务需求弹窗"] attributedMessage:attributedString buttons:@[@"知道了"]];
        }
            break;
        case 11:
        {
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(0, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(31, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(61, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(97, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(140, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(188, 2)];
            //居中属性文本信息
            LBAlertMessage *msg = [[LBAlertMessage alloc]initType:LBAlertMessageTypeAttributedMessage];
            msg.attributedMessage = attributedString;
            msg.textAlignment = NSTextAlignmentCenter;
            [[[[[[LBAlertView new]addTitle:@"议标须知"]addMessage:msg]addButtons:@[@"知道了"]]addCompletedHander:nil
              ]show];

        }
            break;
        case 12:
        {
            //头部图片+普通文本
            LBAlertMessage *msg = [[LBAlertMessage alloc]initType:LBAlertMessageTypeMessage];
            msg.message = @"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间";
            msg.textAlignment = NSTextAlignmentLeft;
            [[[[[[[LBAlertView new]addHeaderImage:[UIImage imageNamed:@"填写服务需求弹窗"]] addMessage:msg]addButtons:@[@"知道了"]] addCompletedHander:nil]addCloseButton
              ]show];
        }
            break;
        case 13:
        {
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(0, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(31, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(61, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(97, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(140, 2)];
            [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:74.0f / 255.0f green:144.0f / 255.0f blue:226.0f / 255.0f alpha:1.0f] range:NSMakeRange(188, 2)];
            //头部图片+富文本
            LBAlertMessage *msg = [[LBAlertMessage alloc]initType:LBAlertMessageTypeAttributedMessage];
            msg.attributedMessage = attributedString;
            msg.textAlignment = NSTextAlignmentLeft;
            
            [[[[[[[LBAlertView new]addHeaderImage:[UIImage imageNamed:@"填写服务需求弹窗"]] addMessage:msg]addButtons:@[@"知道了"]]addCompletedHander:nil
              ]addCloseButton:^(LBAlertView *alertView){
                NSLog(@"右上角关闭按钮事件");
                [alertView dismiss:nil];
            }]show];
        }
            break;
        case 14:
        {
            //带输入框的提示(UITextField)
            [LBAlert showInputTextFieldWithTitle:@"更改数量" message:@"10" limit:50 placeholder:@"在这里填写问题库，最多50字" buttons:@[@"取消",@"保存"] block:^(LBAlertInputTextField *input , NSInteger answer) {
                NSLog(@"点击了按钮%ld",(long)answer);
                NSLog(@"输入了内容:%@",input.textField.text);
            } hasCloseButton:NO];
        }
            break;
        case 15:
        {
            //没有头部的自定义视图
            LBJobInputHunterServiceTipsPopView *tipsView = [[LBJobInputHunterServiceTipsPopView alloc] init];
            LBAlertMessage *msg = [[LBAlertMessage alloc] initType:LBAlertMessageTypeCustomView];
            msg.customView = tipsView;
            msg.customViewInsets = UIEdgeInsetsMake(0, 0, 0, 0);
            
            [[[[[LBAlertView new] addMessage:msg] addButtons:@[@"知道了"]] addCompletedHander:nil] show];
        }
            break;
        case 16:{
            
            [LBAlert say:^(NSInteger answer) {

                
            } title:@"提示一次" message:@"1.在线议标期间，请招投标双方相互尊重、文明用语、诚实表达\t\r2.在线议标期间，请招投标双方仅围绕招标内容进行有效沟通\t\r3.招投标双方的监标人，可监督招投标流程及协助议标，请尊重监标人的意见\r4.在线议标期间，请招标方严禁向任何投标人透露其他投标人的任何信息，包括但不限于价格\r5.在线招标期间，请招标人按照平台设定的问题向投标人提问，尽量不要另设问题，以免影响议标效果\t\n6.请招标人控制议标时间，请在预先设定的时间内完成议标，如需延长议标时间，请务必在议标倒计时结束前申请延长时间"];
            
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [LBActionSheet showImagePickerInView:self.view completion:^(NSDictionary<NSString *,id> *info) {

                }];

            });
            break;
        }
        case 17:{
            //没有脚部的自定义视图
            LBJobInputHunterServiceTipsPopView *tipsView = [[LBJobInputHunterServiceTipsPopView alloc] init];
            LBAlertMessage *msg = [[LBAlertMessage alloc] initType:LBAlertMessageTypeCustomView];
            msg.customView = tipsView;
            msg.customViewInsets = UIEdgeInsetsMake(0, 0, 0, 0);
            
            [[[[[LBAlertView new] addMessage:msg] addCloseButton:^(LBAlertView *alertView) {
                
                [alertView dismiss:^{
                    NSLog(@"关闭了");
                }];
                
            }] addCloseButtonImage:^UIImage *{
                return [UIImage imageNamed:@"LBRecruitOpenVIPView.png"];
            }] show];
        }
            break;
            
            
        default:
            break;
    }

}
@end
